package cn.ren.service;

import cn.ren.dao.LZPermissionDao;
import cn.ren.entity.PageResult;
import cn.ren.entity.Result;
import cn.ren.pojo.LZOrderShow;
import cn.ren.pojo.Permission;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;

@Service(interfaceClass =LZPermissionService.class)
public class LZPermissionServiceImpl implements LZPermissionService {
    @Autowired
    LZPermissionDao lzPermissionDao;
    @Override
    public PageResult queryPage(Integer currentPage, Integer pageSize, String queryString) {
        PageHelper.startPage(currentPage, pageSize);
        Page<Permission> page = lzPermissionDao.findByCondition(queryString);
        return new PageResult(page.getTotal(), page.getResult());
    }

    @Override
    public Result add(Permission permission) {
        try {
            lzPermissionDao.add(permission);

        } catch (Exception e) {
            e.printStackTrace();
            return new Result(true, "权限创建失败");
        }
        return new Result(true, "权限创建成功");
    }
}
